package com.jin.webvideo.base.spring.thymeleaf;

import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.StandardDialect;

import java.util.HashSet;
import java.util.Set;

/**
 * thymeleaf 权限（permission）标签
 */
public class PermissionProcessorDialect extends AbstractProcessorDialect {
    private static final String DIALECT_NAME = "PermissionDialect";
    private static final String PREFIX = "permission";

    public PermissionProcessorDialect() {
        super(DIALECT_NAME, PREFIX, StandardDialect.PROCESSOR_PRECEDENCE);
    }

    @Override
    public Set<IProcessor> getProcessors(String s) {
        Set<IProcessor> processors = new HashSet<>();
        processors.add(new LoginProcessor(PREFIX));
        processors.add(new RoleProcessor(PREFIX));
        return processors;
    }
}
